```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>设计模式精要：单一职责原则</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma,Arial,Roboto,"Droid Sans","Helvetica Neue","Droid Sans Fallback","Heiti SC","Hiragino Sans GB",Simsun,sans-serif;
            color: #333;
            line-height: 1.8;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #6e8efb 0%, #a777e3 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .drop-cap:first-letter {
            float: left;
            font-size: 4rem;
            line-height: 0.8;
            margin: 0.2em 0.1em 0 0;
            color: #6e8efb;
            font-weight: 700;
        }
    </style>
</head>
<body class="antialiased">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-4 md:px-0">
        <div class="container mx-auto max-w-5xl px-4">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-1/2 mb-10 md:mb-0">
                    <h1 class="text-4xl md:text-5xl font-bold leading-tight mb-4 font-serif">单一职责原则</h1>
                    <p class="text-xl mb-6 opacity-90">SOLID设计原则的基石</p>
                    <p class="text-lg opacity-80">一个类应该只有一个引起它变化的原因，即一个类应该只有一个责任。</p>
                    <div class="mt-8 flex space-x-4">
                        <a href="#explanation" class="bg-white text-indigo-600 px-6 py-3 rounded-full font-medium hover:bg-gray-100 transition duration-300 inline-flex items-center">
                            <i class="fas fa-book mr-2"></i> 深入了解
                        </a>
                        <a href="#example" class="border border-white text-white px-6 py-3 rounded-full font-medium hover:bg-white hover:text-indigo-600 transition duration-300 inline-flex items-center">
                            <i class="fas fa-code mr-2"></i> 查看示例
                        </a>
                    </div>
                </div>
                <div class="md:w-1/2">
                    <div class="bg-white rounded-xl p-4 shadow-2xl">
                        <div class="mermaid">
                            graph TD
                            A[Employee] -->|违反SRP| B[管理信息]
                            A -->|违反SRP| C[计算薪资]
                            D[EmployeeInfo] -->|遵循SRP| E[仅管理信息]
                            F[SalaryCalculator] -->|遵循SRP| G[仅计算薪资]
                            style A fill:#fecaca,stroke:#f87171
                            style D fill:#bbf7d0,stroke:#4ade80
                            style F fill:#bbf7d0,stroke:#4ade80
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto max-w-5xl px-4 py-16">
        <!-- Explanation Section -->
        <section id="explanation" class="mb-20">
            <div class="flex items-center mb-10">
                <div class="w-12 h-1 bg-indigo-500 rounded-full mr-4"></div>
                <h2 class="text-3xl font-bold text-gray-800 font-serif">核心解释</h2>
            </div>
            
            <div class="grid grid-cols-1 md:grid-cols-2 gap-8 mb-12">
                <div class="bg-white p-8 rounded-xl shadow-md card-hover">
                    <div class="text-indigo-500 text-4xl mb-4">
                        <i class="fas fa-bullseye"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3">单一职责</h3>
                    <p class="text-gray-600">每个类应该只有一个主要功能或职责。这个职责的改变应该只影响到这个类，而不会对其他类产生影响。</p>
                </div>
                
                <div class="bg-white p-8 rounded-xl shadow-md card-hover">
                    <div class="text-indigo-500 text-4xl mb-4">
                        <i class="fas fa-exchange-alt"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3">引起变化的原因</h3>
                    <p class="text-gray-600">如果一个类有多个职责，那么当其中一个职责发生变化时，可能会影响到其他职责，从而导致类的复杂性增加。</p>
                </div>
            </div>
            
            <div class="bg-gray-50 p-8 rounded-xl">
                <p class="drop-cap text-gray-700">遵循单一职责原则可以减少这种影响，使得系统更加模块化和易于维护。高内聚、低耦合的代码结构能够显著提升软件的质量，使系统在面对需求变更时更加灵活。</p>
            </div>
        </section>

        <!-- Example Section -->
        <section id="example" class="mb-20">
            <div class="flex items-center mb-10">
                <div class="w-12 h-1 bg-indigo-500 rounded-full mr-4"></div>
                <h2 class="text-3xl font-bold text-gray-800 font-serif">代码示例</h2>
            </div>
            
            <div class="grid grid-cols-1 md:grid-cols-2 gap-8 mb-12">
                <div>
                    <div class="bg-gray-800 rounded-t-xl p-4 flex items-center">
                        <div class="w-3 h-3 rounded-full bg-red-500 mr-2"></div>
                        <div class="w-3 h-3 rounded-full bg-yellow-500 mr-2"></div>
                        <div class="w-3 h-3 rounded-full bg-green-500"></div>
                        <span class="text-gray-400 ml-4 text-sm">违反SRP的代码</span>
                    </div>
                    <div class="bg-gray-900 p-6 rounded-b-xl">
                        <pre class="text-gray-300 text-sm overflow-x-auto"><code>// 违反单一职责原则的类
public class Employee {
    private String name;
    private String position;
    
    // 基本信息管理方法
    public void updateName(String newName) { ... }
    public void updatePosition(String newPosition) { ... }
    
    // 薪资计算方法
    public double calculateSalary() { ... }
    public void generatePaySlip() { ... }
}</code></pre>
                    </div>
                </div>
                
                <div>
                    <div class="bg-gray-800 rounded-t-xl p-4 flex items-center">
                        <div class="w-3 h-3 rounded-full bg-red-500 mr-2"></div>
                        <div class="w-3 h-3 rounded-full bg-yellow-500 mr-2"></div>
                        <div class="w-3 h-3 rounded-full bg-green-500"></div>
                        <span class="text-gray-400 ml-4 text-sm">遵循SRP的代码</span>
                    </div>
                    <div class="bg-gray-900 p-6 rounded-b-xl">
                        <pre class="text-gray-300 text-sm overflow-x-auto"><code>// 遵循单一职责原则的拆分
public class EmployeeInfo {
    private String name;
    private String position;
    
    // 仅包含基本信息管理方法
    public void updateName(String newName) { ... }
    public void updatePosition(String newPosition) { ... }
}

public class SalaryCalculator {
    // 仅包含薪资计算方法
    public double calculateSalary(EmployeeInfo emp) { ... }
    public void generatePaySlip(EmployeeInfo emp) { ... }
}</code></pre>
                    </div>
                </div>
            </div>
            
            <div class="bg-indigo-50 p-8 rounded-xl border-l-4 border-indigo-500">
                <h3 class="text-xl font-bold text-indigo-800 mb-4 flex items-center">
                    <i class="fas fa-lightbulb mr-3"></i> 重构建议
                </h3>
                <p class="text-indigo-700">当您发现一个类包含"并且"描述时(如"管理员工信息并且计算薪资")，这通常违反了单一职责原则。考虑将这些职责拆分到不同的类中，每个类专注于一个明确的功能。</p>
            </div>
        </section>

        <!-- Benefits Section -->
        <section class="mb-20">
            <div class="flex items-center mb-10">
                <div class="w-12 h-1 bg-indigo-500 rounded-full mr-4"></div>
                <h2 class="text-3xl font-bold text-gray-800 font-serif">优势分析</h2>
            </div>
            
            <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
                <div class="bg-white p-6 rounded-xl shadow-sm border-t-4 border-green-500 card-hover">
                    <h3 class="text-lg font-bold mb-3 flex items-center">
                        <i class="fas fa-wrench text-green-500 mr-2"></i> 可维护性
                    </h3>
                    <p class="text-gray-600">由于每个类的职责单一，修改某个功能时不会影响到其他功能，从而降低了系统的复杂性。</p>
                </div>
                
                <div class="bg-white p-6 rounded-xl shadow-sm border-t-4 border-blue-500 card-hover">
                    <h3 class="text-lg font-bold mb-3 flex items-center">
                        <i class="fas fa-recycle text-blue-500 mr-2"></i> 复用性
                    </h3>
                    <p class="text-gray-600">单一职责的类通常功能明确，更容易被其他类或系统复用。</p>
                </div>
                
                <div class="bg-white p-6 rounded-xl shadow-sm border-t-4 border-purple-500 card-hover">
                    <h3 class="text-lg font-bold mb-3 flex items-center">
                        <i class="fas fa-brain text-purple-500 mr-2"></i> 理解性
                    </h3>
                    <p class="text-gray-600">功能明确的类更容易被理解和管理，有助于开发人员快速上手和维护代码。</p>
                </div>
            </div>
        </section>

        <!-- Visualization Section -->
        <section class="mb-20">
            <div class="flex items-center mb-10">
                <div class="w-12 h-1 bg-indigo-500 rounded-full mr-4"></div>
                <h2 class="text-3xl font-bold text-gray-800 font-serif">关系可视化</h2>
            </div>
            
            <div class="bg-white p-6 rounded-xl shadow-md">
                <div class="mermaid">
                    flowchart TD
                    subgraph 违反SRP
                        A[Employee类] --> B[管理信息]
                        A --> C[计算薪资]
                        A --> D[考勤管理]
                        style A stroke:#f87171,stroke-width:3px
                    end
                    
                    subgraph 遵循SRP
                        E[EmployeeInfo] --> F[仅管理信息]
                        G[SalaryCalculator] --> H[仅计算薪资]
                        I[AttendanceTracker] --> J[仅考勤管理]
                        style E stroke:#4ade80,stroke-width:3px
                        style G stroke:#4ade80,stroke-width:3px
                        style I stroke:#4ade80,stroke-width:3px
                    end
                </div>
                <p class="mt-6 text-gray-600 text-center">通过将多功能类拆分为多个单一职责类，系统结构变得更加清晰，各组件之间的耦合度显著降低。</p>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-12">
        <div class="container mx-auto max-w-5xl px-4">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <h3 class="text-xl font-bold text-white mb-2">技术小馆</h3>
                    <p class="text-gray-400">探索编程艺术，品味设计之美</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="text-indigo-400 hover:text-indigo-300 transition duration-300 flex items-center">
                        <i class="fas fa-external-link-alt mr-2"></i> 访问技术小馆
                    </a>
                </div>
            </div>
            <div class="border-t border-gray-800 mt-8 pt-8 text-center text-gray-500 text-sm">
                <p>© 2023 技术小馆 - 专注分享编程知识与设计理念</p>
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            },
            themeVariables: {
                primaryColor: '#EDF2F7',
                primaryBorderColor: '#4C51BF',
                primaryTextColor: '#1A202C',
                lineColor: '#A0AEC0'
            }
        });
        
        // 平滑滚动
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                document.querySelector(this.getAttribute('href')).scrollIntoView({
                    behavior: 'smooth'
                });
            });
        });
    </script>
</body>
</html>
```